//
//  GLEnemyView.m
//  QAQ打飞机
//
//  Created by admin on 15/9/1.
//  Copyright (c) 2015年 gl. All rights reserved.
//

#import "GLEnemyView.h"

@implementation GLEnemyView

-(id)initWithEnemy:(GLEnemy *)enemy imagesRes:(GLImageResource *)imageRes
{
    self =[super init];
    if (self !=nil) {
        self.enemy=enemy;
        //int i =arc4random_uniform(40);
        //图像
        switch (enemy.type) {
            case kEnemySmall:
            
                self.image =imageRes.smallEnemyFlyImage;
                self.hitImage =nil;
                self.blowupImages =imageRes.smallenemyBlowpImages;
                [self setFrame:CGRectMake(0, 0, self.image.size.width/3.0, self.image.size.height/3.0)];
                break;
            case kEnemyMid:
                self.image =imageRes.midEnemyFlyImage;
                self.blowupImages =imageRes.midEnemyBlowupImages;
                self.hitImage =imageRes.midEnemyHitImage;
                [self setFrame:CGRectMake(0, 0, self.image.size.width/1.5, self.image.size.height/1.5)];
                break;
            case kEnemyBig:
                self.image =imageRes.bigEnemyFlyImages;
                self.hitImage =imageRes.bigEnemyHitImage;
                self.blowupImages =imageRes.bigEnemyBlowupImages;
                [self setFrame:CGRectMake(0, 0, self.image.size.width, self.image.size.height)];
                break;
            default:
                break;
        }
        //设置视图的边框和中心点
        //[self setFrame:CGRectMake(0, 0, self.image.size.width/2.5, self.image.size.height/2.5)];
        [self setCenter:enemy.position];
    }

    return self;
}
@end
